package com.zyz.M_File和IO流.IO流.对象流;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author: vick
 * @Date: 2025/4/10
 * @Description:
 * @version: 1.0
 */
//序列化
public class PersonWrite {
    public static void main(String[] args) throws IOException {
        Person.setCompany("字节");
        Person person = new Person("vick", "常州", 25);
        File file = new File("person.dat");
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
        objectOutputStream.writeObject(person);
        objectOutputStream.close();

    }
}
